package org.keyuan.struts1.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.keyuan.entity.Author;
import org.keyuan.entity.Book;
import org.keyuan.entity.BookDetail;
import org.keyuan.entity.BookType;
import org.keyuan.entity.Press;

public class BookForm extends BaseForm {

	private static final long serialVersionUID = 9122548345302473701L;
	
	private Book book=new Book();
	public BookForm() {
		if(book.getBookType()==null){
			BookType bookType=new BookType();
			bookType.setTypeId(null);
			book.setBookType(bookType);
		}
		if(book.getAuthor()==null){
			Author  author=new Author();
			author.setAuthorId(null);
			book.setAuthor(author);
		}
		if(book.getPress()==null){
			Press  press=new Press();
			press.setPressId(null);
			book.setPress(press);
		}
		if(book.getBookDetail()==null){
		BookDetail bookDetail=new BookDetail();
		bookDetail.setBook(book);
		book.setBookDetail(bookDetail);
		}
	}
	private FormFile imageFile;
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public FormFile getImageFile() {
		return imageFile;
	}

	public void setImageFile(FormFile imageFile) {
		this.imageFile = imageFile;
	}
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		book.getBookDetail().setDetailId(null);
		super.reset(mapping, request);
	}
}
